********************************************************************************
**	PURPOSE: Do the tabulations to fill out Figure 2
**							
**	INPUTS: Long with outcomes.dta
**			Wide with outcomes.dta 
**			
** 	CREATED/MODIFIED BY: Peter Lugthart, Hasan Ahamed
**
**	DATE CREATED: 09/28/20, 2/19/2023
********************************************************************************

clear all
	
use "$adta/Long with outcomes.dta", clear

* Number of people interested in CBL:
preserve
use "$adta/Wide with outcomes.dta", clear 
count if flag_randomized == 1	//1531
restore 
* In bureau data
areg scoredf enc if flag_randomized == 1, absorb(surveyid) vce(cluster surveyid)
di "`e(df_a)'"	//this plus 1 = 1507
				
	* Number of people interested in CBL, in CBL arm:
	preserve
	use "$adta/Wide with outcomes.dta", clear 
	count if flag_randomized == 1 & enc==1	//789
	restore 
	* In bureau data
	areg scoredf enc if flag_randomized == 1 & enc==1, absorb(surveyid) vce(cluster surveyid)
	di "`e(df_a)'" //this plus 1 = 775 

		* Number of people interested in CBL, in CBL arm, who opened a CBL:
		preserve
		use "$adta/Wide with outcomes.dta", clear 
		count if flag_randomized == 1 & enc==1 & op18==1	//233
		restore 
		* In bureau data
		areg scoredf enc if flag_randomized == 1 & enc==1 & op18==1, absorb(surveyid) vce(cluster surveyid)
		di "`e(df_a)'" //this plus 1 = 232

			* Number of people interested in CBL, in CBL arm, who opened a CBL, who had any delinquency:
			preserve
			use "$adta/Wide with outcomes.dta", clear 
			count if flag_randomized == 1 & enc==1 & op18==1 & (bin30acctsdl6==1 | bin30acctsdl12==1 | bin30acctsdl18==1) //163---------INCORRECT VARIABLE SPECIFICATION
			restore 
			* In bureau data
			areg scoredf enc if flag_randomized == 1 & enc==1 & op18==1 & cm30plus==1, absorb(surveyid) vce(cluster surveyid)
			di "`e(df_a)'" //this plus 1 = 96
			
			* Number of people interested in CBL, in CBL arm, who opened a CBL, who did not have any delinquency:
			preserve
			use "$adta/Long with outcomes.dta", clear 
			count if flag_randomized == 1 & enc==1 & op18==1 & (bin30acctsdl6==0 & bin30acctsdl12==0 & bin30acctsdl18==0) //68---------INCORRECT VARIABLE SPECIFICATION
			restore 
		 	* In bureau data
			areg scoredf enc if flag_randomized == 1 & enc==1 & op18==1 & cm30plus==0, absorb(surveyid) vce(cluster surveyid)
			di "`e(df_a)'" //this plus 1 = 136	
			
		* Number of people interested in CBL, in CBL arm, who did not open a CBL:
		preserve
		use "$adta/Wide with outcomes.dta", clear 
		count if flag_randomized == 1 & enc==1 & op18==0 //556
		restore 
		* In bureau data
		areg scoredf enc if flag_randomized == 1 & enc==1 & op18==0, absorb(surveyid) vce(cluster surveyid)
		di "`e(df_a)'" //this plus 1 = 543

	* Number of people interested in CBL, in Extra Step arm: 
	preserve
	use "$adta/Wide with outcomes.dta", clear 
	count if flag_randomized == 1 & enc==0		//742
	restore 
	* In bureau data
	areg scoredf enc if flag_randomized == 1 & enc==0, absorb(surveyid) vce(cluster surveyid)
	di "`e(df_a)'" //this plus 1 = 732
	
		* Number of people interested in CBL, in Extra Step arm, who opened a CBL:
		preserve
		use "$adta/Wide with outcomes.dta", clear 
		count if flag_randomized == 1 & enc==0 & op18==1	//87
		restore 
		* In bureau data
		areg scoredf enc if flag_randomized == 1 & enc==0 & op18==1, absorb(surveyid) vce(cluster surveyid)
		di "`e(df_a)'" //this plus 1 = 86

			* Number of people interested in CBL, in Extra Step arm, who opened a CBL, who had any delinquency:
			preserve
			use "$adta/Wide with outcomes.dta", clear 
			count if flag_randomized == 1 & enc==0 & op18==1 & (bin30acctsdl6==1 | bin30acctsdl12==1 | bin30acctsdl18==1) //54---------INCORRECT VARIABLE SPECIFICATION
			restore 
			* In bureau data
			areg scoredf enc if flag_randomized == 1 & enc==0 & op18==1 & cm30plus==1, absorb(surveyid) vce(cluster surveyid)
			di "`e(df_a)'" //this plus 1 = 26
			
			* Number of people interested in CBL, in Extra Step arm, who opened a CBL, who did not have any delinquency:
			preserve
			use "$adta/Wide with outcomes.dta", clear 
			count if flag_randomized == 1 & enc==0 & op18==1 & (bin30acctsdl6==0 & bin30acctsdl12==0 & bin30acctsdl18==0) //32---------INCORRECT VARIABLE SPECIFICATION
			restore 
			* In bureau data
			areg scoredf enc if flag_randomized == 1 & enc==0 & op18==1 & cm30plus==0, absorb(surveyid) vce(cluster surveyid)
			di "`e(df_a)'" //this plus 1 = 60
			
		* Number of people interested in CBL, in Extra Step arm, who did not open a CBL:
		preserve
		use "$adta/Wide with outcomes.dta", clear 
		count if flag_randomized == 1 & enc==0 & op18==0 //655
		restore 
		* In bureau data
		areg scoredf enc if flag_randomized == 1 & enc==0 & op18==0, absorb(surveyid) vce(cluster surveyid)
		di "`e(df_a)'" //this plus 1 = 646
		

* Number of people uninterested in CBL 
preserve
use "$adta/Wide with outcomes.dta", clear 
count if flag_randomized == 0	//738
restore 
* In bureau data
areg scoredf if flag_randomized == 0, absorb(surveyid) vce(cluster surveyid)
di "`e(df_a)'"	//this plus 1 = 725
		
				
		
		
		
		
		